/*
 * trcmd_result_access.c
 *
 *  Created on: 2012/08/13
 *      Author: guanxiaoying
 */
#include "../tracedef.h"
#include "../trace_cmd/trace_cmd.h"


TYPE_TRACEPATHINFO DLL_EXPORT TracePathInfo ;
EXTERNAL_SYMBOL(TracePathInfo );

static BOOL getPathCondition( AST astPath ){
	return (stCmdPathInfoAccess.condition.get( astPath ) != PATH_FALSE);
}
static AST getPathInfoOfFunction( PSZ pszFunc, PSZ pszFile ){
	AST astCnt;
	AST astCodeScope;
	AST astMax = LinkFunction.getMax();
	PSZ pszName;

	for( astCnt = MIN_ARRAY; astCnt <= astMax; astCnt++ ){
		pszName = LinkFunction.getName( astCnt );
		if( strcmp( pszName, pszFunc ) == 0 ){
			astCodeScope = LinkFunction.getCodeScope( astCnt );
			pszName = CCodeScope.getLastSegmentName( astCodeScope, 1 );
			if( strncasecmp( pszName, pszFunc, strlen(pszName) ) == 0 ){
				return stTrFunctionAccess.pathInfo.get( astCnt );
			}
		}
	}
	return 0;
}
VOID TracePathInfoInit( VOID ){
	TracePathInfo.getBackwardPath = stCmdPathInfoAccess.pathIn.get;
	TracePathInfo.getBeginCommand = stCmdPathInfoAccess.beginNode.get;
	TracePathInfo.getEndCommand = stCmdPathInfoAccess.endNode.get;
	TracePathInfo.getForwardPath = stCmdPathInfoAccess.pathOut.get;
	TracePathInfo.getLoopInfo = stCmdPathInfoAccess.loopInfo.get;
	TracePathInfo.getParallelPathBackward = stCmdPathInfoAccess.pathIn_next.get;
	TracePathInfo.getParallelPathForward = stCmdPathInfoAccess.pathOut_next.get;
	TracePathInfo.getPathCondition = getPathCondition;
	TracePathInfo.getPathInfoOfFunction =getPathInfoOfFunction;
	TracePathInfo.getTotalTracedTimes = stCmdPathInfoAccess.totalTimes.get;
}
TYPE_TRACECOMMANDLISTMETADATA  DLL_EXPORT TraceCmdListMetaData;
EXTERNAL_SYMBOL(TraceCmdListMetaData );
VOID TraceCmdListMetaDataInit( VOID ){
	TraceCmdListMetaData.getLoopInfo = stCmdListMetaAccess.loopInfo.get;
	TraceCmdListMetaData.getInputPath = stCmdListMetaAccess.pathIn.get;
	TraceCmdListMetaData.getOutputPath = stCmdListMetaAccess.pathOut.get;
	TraceCmdListMetaData.getPathInfo = stCmdListMetaAccess.pathInfo.get;
}
TYPE_TRACELOOPINFO  DLL_EXPORT TraceLoopInfo ;
EXTERNAL_SYMBOL(TraceLoopInfo );
VOID TraceLoopInfoInit( VOID ){
	TraceLoopInfo.getEntryPath = stCmdLoopInfoAccess.begin.get;
	TraceLoopInfo.getParentLoop = stCmdLoopInfoAccess.parent.get;
}
